package com.rc.saas.tenant.service.channel;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.tenant.mapper.channel.RcChannelLevelSettingMapper;
import com.rc.saas.tenant.model.channel.RcChannelLevelSetting;
import com.rc.saas.tenant.model.channel.RcChannelLevelSettingExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RcChannelLevelSettingServiceImpl implements RcChannelLevelSettingService{
    @Autowired
    private RcChannelLevelSettingMapper channelLevelSettingMapper;

    @Override
    public RcChannelLevelSettingMapper getMapper() {
        return channelLevelSettingMapper;
    }

    @Override
    public PageInfo listPageChannelLevel(String levelName, Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<RcChannelLevelSetting> list = channelLevelSettingMapper.listChannelLevel(levelName);
        return new PageInfo(list);
    }

    @Override
    public List<RcChannelLevelSetting> listEnabledChannelLevel() {
        RcChannelLevelSettingExample example = new RcChannelLevelSettingExample();
        example.createCriteria().andStatusEqualTo("0").andChannelLevelNotEqualTo("S0");
        return channelLevelSettingMapper.selectByExample(example);
    }
}
